﻿Imports ComponentFactory.Krypton.Toolkit

Public Class Splash
    Inherits KryptonForm

    Private WithEvents timer As Timer
    Private cont, max As Integer
    Private WithEvents frm As Principal

    Sub New(ByVal tempo As Integer)

        ' This call is required by the Windows Form Designer.
        InitializeComponent()
        ' Add any initialization after the InitializeComponent() call.

        timer = New Timer()
        timer.Interval = 1000

        max = tempo

    End Sub

    Private Sub timerHandler(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles timer.Tick
        cont += 1
        If (cont = max) Then
            timer.Stop()
            frm = New Principal()
            frm.ShowDialog()
            Me.Visible = False
        End If
    End Sub

    Private Sub Splash_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        timer.Start()
    End Sub

    Private Sub frm_Closed(ByVal sender As Object, ByVal e As System.EventArgs) Handles frm.FormClosed
        If (frm.IsDisposed) Then
            Me.Dispose()
        End If
    End Sub

    Private Sub Splash_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Click
        timer.Interval = 1
    End Sub

    Private Sub Splash_Shown(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Shown
        'Quando carregar a tela de splash, a painel flash da tela principal também é carregado.
        Principal.flashPanel.Movie = Config.DiretorioPainelFlash

        'Carrega as DLLs do Crystal Report
        Dim d As New CrystalDecisions.CrystalReports.Engine.ReportDocument()
        d.Load(Config.DiretorioAplicacao & "/../../../Relatorio/Entradas.rpt")
    End Sub
End Class